<template>
  <div class="pub-box">
    <!-- 顶部 -->
    <div class="title">
      <span
        class="s-off"
        @click="$router.back()"
      >

        <van-icon
          name="cross"
          size="60px"
          color="white"
        />

      </span>

      <span
        class="s-fa"
        @click="adds"
      >
        <router-link to="/user/info" >
          
        </router-link>
        发布
      </span>
    </div>
    <!-- 内容 -->
    <div class="inp">
      <textarea
        placeholder="记录这一刻"
        v-model.trim="message"
        @input="chang"
      >

       </textarea>
      <van-uploader
        class="addimg"
        v-model="fileList"
        preview-size="150"
        multiple
      />
      <div class="huati">
        <van-checkbox-group
          v-model="result"
          icon-size="30"
        >
          <van-checkbox
            name="a"
            shape="square"
          >你在哪里</van-checkbox>
          <van-checkbox
            name="b"
            shape="square"
          >添加话题</van-checkbox>
        </van-checkbox-group>
        <span class="ed">@ta</span>
      </div>
      <!--  -->
      <div class="lis">
        <li>血染讨论区</li>
        <li>血染讨论区</li>
        <li>血染讨论区</li>
        <li>血染讨论区</li>
      </div>
    </div>
  </div>
</template>

<script>

import { postDynamic } from "@/services";
export default {
  data() {
    return {
      fileList: [
        /* { url: 'https://img01.yzcdn.cn/vant/leaf.jpg' },
        // Uploader 根据文件后缀来判断是否为图片文件
        // 如果图片 URL 中不包含类型信息，可以添加 isImage 标记来声明
        { url: 'https://cloud-image', isImage: true }, */
      ],
      result: ["a", "b"],
      message: "",
    };
  },
  methods: {
    chang() {
      console.log(this.message);
    },
      adds() {
          if (this.message != "") {
            console.log(1);
            postDynamic({ message: this.message,uid:localStorage.getItem("uids")}).then((res) => {
        // console.log(res.data);
        this.$router.push("/user/info")
      });
          } else {
            this.$toast('发送内容不能为空');
        }
      
    },
  },
  created() {
    
    // console.log(this.message);
    },
  mounted() {
    
  },
};
</script>

<style lang="scss" >
.pub-box {
  color: white;
  width: 90%;
  margin: 0 auto;
  .van-toast{
    font-size: 30px;
    width: 200px;
    height: 50px;
  }
  a {
    list-style: none;
  }
  .title {
    width: 100%;
    height: 60px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    .s-off {
      font-size: 30px;
    }
    .s-fa {
      width: 120px;
      height: 60px;
      background-color: rgba(164, 173, 179, 100);
      border-radius: 30px;
      text-align: center;
      line-height: 60px;
      font-size: 28px;
    }
  }
  .inp {
    width: 100%;
    // height: 500px;
    font-size: 30px;
    line-height: 20px;
    background-color: white;
    textarea {
      width: 100%;
      height: 300px;
      line-height: 50px;
      padding: 20px;
      font-size: 30px;
      text-indent: 30px;
      border: none;
      color: black;
    }
    .addimg {
      // background-color: #CECECE;
      margin: 20px 0;
      left: 20px;
    }
    .huati {
      width: 40%;
      display: flex;
      justify-content: space-between;
      // align-items: center;
      .ed {
        width: 100px;
        height: 46px;
        text-align: center;
        line-height: 46px;
        color: red;
        font-size: 25px;
        border-radius: 24px;
        background-color: rgba(255, 255, 255, 100);
        color: rgba(154, 154, 154, 100);
        border: 1px solid rgba(187, 187, 187, 100);
      }
    }
    .van-checkbox {
      width: 200px;
      background-color: rgba(255, 255, 255, 100);
      margin: 20px 0;
      height: 50px;
      font-size: 30px;
    }
    .lis {
      width: 98%;
      margin: 30px auto;
      height: 100px;
      display: flex;
      justify-content: space-between;
      li {
        width: 160px;
        height: 50px;
        background-color: rgba(164, 173, 179, 100);
        border-radius: 30px;
        line-height: 50px;
        font-size: 25px;
        text-align: center;
      }
    }
  }
}
</style>